#//@reference Agile Web Development with Rails (4th Edition) (Whitney, Clare x11106131)

class UsersController < ApplicationController
  def new
    @user = User.new
    @cart = current_cart
  end

def create
  @user = User.new(params[:user])
  if @user.save
    redirect_to products_path, :notice => 'User creation successful! '
  else
    render :action => 'new'
  end

end

   def index
    @users = User.search(params[:search_query])
    @cart = current_cart


    respond_to do |format|
      format.html # index.html.erb
      format.json { render :json => @users }
    end
   end

    def show
    @cart = current_cart
    @user = User.find(params[:id])
    @orders = @user.orders

    respond_to do |format|
      format.html # show.html.erb
      format.json { render :json => @user }
    end
  end

end
